(ns cljsso.utils)



(defn register-shutdownhook
  "Add func as a shutdownhook. This function will be executed when JVM
  termination signal received."
  [func & args]
  (.addShutdownHook
   (Runtime/getRuntime)
   (Thread.
    #(apply func args))))


(defn gen-uid-key
  "Create key for identifying user session"
  [uid skey]
  (str uid ":" skey))


(defn find-host
  "Get host address from a url"
  [url]
  (when url
    (last
     (re-find  #"(https?://[\w\.\-]+\w)/?" url))))
